package com.lhc.bean.aware;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanClassLoaderAware;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.BeanFactoryAware;
import org.springframework.beans.factory.BeanNameAware;
import org.springframework.stereotype.Component;

/**
 * @author LuHuanCheng
 * 类说明：aware接口实现类的测试
 * 下面三个方法的调用是在AwareBean实例化以后   AbstractAutowireCapableBeanFactory类的initializeBean方法的invokeAwareMethods
 */
@Component
public class AwareBean implements BeanNameAware, BeanFactoryAware, BeanClassLoaderAware {
    @Override
    public void setBeanName(String name) {
        System.out.println("AwareBean之beanName：" + name);
    }

    @Override
    public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
        System.out.println("AwareBean之beanFactory：" + beanFactory);
    }

    @Override
    public void setBeanClassLoader(ClassLoader classLoader) {
        System.out.println("AwareBean之classLoader：" + classLoader);
    }
}